package com.ddmmo.exhibition.localBOSS.examination.controller;

import com.ddmmo.exhibition.common.annotation.WebLog;
import com.ddmmo.exhibition.common.entity.Result;
import com.ddmmo.exhibition.localBOSS.examination.entity.po.KsAnswersPO;
import com.ddmmo.exhibition.localBOSS.examination.entity.po.KsExamsPO;
import com.ddmmo.exhibition.localBOSS.examination.entity.po.KsQuestionsPO;
import com.ddmmo.exhibition.localBOSS.examination.entity.ro.EndExamRO;
import com.ddmmo.exhibition.localBOSS.examination.entity.vo.AllHistoryVO;
import com.ddmmo.exhibition.localBOSS.examination.entity.vo.EndExamVO;
import com.ddmmo.exhibition.localBOSS.examination.entity.vo.StartExamVO;
import com.ddmmo.exhibition.localBOSS.examination.service.ExamService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 考试模块 - Controller
 * </p>
 *
 * @author JiangYiji
 * @since 2024/10/30
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/exam")
@Api(tags = "考试模块-Controller")
public class ExamController {

    @Autowired
    private ExamService examService;

    /**
     * 开始考试
     */
    @WebLog
    @PostMapping("/startExam")
    @ApiOperation(value = "开始考试")
    public Result<StartExamVO> startExam(@RequestParam Integer questionFashionType) {
        log.info("开始考试 - 考试类型: {}", questionFashionType);
        Result<StartExamVO> examResult = examService.startExam(questionFashionType);
        return examResult;
    }

    /**
     * 结束考试
     */
    @WebLog
    @PostMapping("/endExam")
    @ApiOperation(value = "结束考试")
    public Result endExam(@RequestBody EndExamRO answers) {
        log.info("【考试模块-提交答案】考试答卷：{}", answers);
        EndExamVO endExamVO = examService.endExam(answers);
        return Result.success(endExamVO);
    }

    /**
     * 查看历史记录
     */
    @WebLog
    @GetMapping("/allHistory")
    @ApiOperation(value = "查看历史记录")
    public Result<AllHistoryVO> allHistory() {
        AllHistoryVO history = examService.allHistory();
        return Result.success(history);
    }

}
